package com.google.gwt.sample.stockwatcher.client.view;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.sample.stockwatcher.client.StockWatcher;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;

public class TablaFlexible extends StockWatcher {

    public TablaFlexible() {
    	// Tables have no explicit size -- they resize automatically on demand.
    	FlexTable t = new FlexTable();
    	final Button secondButton = new Button("Click me!!!");
    	final HTML texto = new HTML("<h1> text </h1>");
    	
    	// Put some text at the table's extremes.  This forces the table to be
    	// 3 by 3.
    	t.setText(0, 0, "upper-left corner");    	
    	t.setText(2, 2, "bottom-right corner");
    	
    	// Let's put a button in the middle...
    	t.setWidget(1, 0, secondButton);
    	
    	// ...and set it's column span so that it takes up the whole row.
    	t.getFlexCellFormatter().setColSpan(1, 0, 3);
    	t.setBorderWidth(1);
    	t.setCellPadding(5);
    	
    	RootPanel.get("flexTable").add(t);
		
    	
		// Add a handler to close the DialogBox
		secondButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				CustomDialogBox dialogBox = new CustomDialogBox(texto);
				dialogBox.center();
				dialogBox.show();
				secondButton.setEnabled(true);
				secondButton.setFocus(true);
			}
		});
    	
	}
    
    

    
}
